import 'package:package_info_plus/package_info_plus.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:yqmssa_app/views/splash_methods.dart';

///应用基础配置
class AppConfig {
  AppConfig._();

  ///应用名称
  static const String appName = '逾期马上上岸';

  ///应用包名
  static String packageName = _packageInfo.packageName;

  static late PackageInfo _packageInfo;

  ///备案号
  static const String recordNumber = "渝ICP备2023011265号-6A";

  static Future init() async {
    _packageInfo = await PackageInfo.fromPlatform();
  }

  ///应用版本号
  static String get version => _packageInfo.version;

  static const _channelF = "o";

  ///应用图标
  static String get appLogo {
    switch (channel) {
      default:
        return imagePath("logo.png");
    }
  }

  ///渠道
  static String get channel {
    switch (_channelF) {
      case "o":
        return "oppo";
      case "v":
        return "vivo";
      case "h":
        return "huawei";
      case "x":
        return "xiaomi";
      case "r":
        return "rongyao";
      case "y":
        return "yingyongbao";
      default:
        return "";
    }
  }

  static String appBundleLabel = "yqmssa_$channel";

  static String imagePath(String path) {
    return "assets/images/$path";
  }

  static AppInitDM appInitData = AppInitDM();

  static XieYiDM xieYIData = XieYiDM();

  static Future<bool> launchLink(String url) {
    final uri = Uri.parse(url);
    return launchUrl(uri);
  }

  static Future<bool> launchPhone(String phone) {
    final uri = Uri.parse("tel:$phone");
    return launchUrl(uri);
  }
}
